import React, { Component } from "react";
import Child from "./Child";

// 16.3版本开始删除了componentWillMount，componentWillUpdate，componentWillReceiveProps
// 新增了getDerivedStateFromProps和getSnapshotBeforeUpdate
class App extends Component {
  state = {
    count: 10,
  };

  render() {
    return (
      <>
        <h2>新版生命周期(16.3版本之后)</h2>
        <Child count={this.state.count} />
      </>
    );
  }

  componentDidMount() {
    setTimeout(() => {
      this.setState({
        count: 20,
      });
    }, 2000);
  }
}

export default App;
